﻿using NUnit.Framework;

namespace PhotoFramePublishingPlugin.Tests
{
    [TestFixture]
    public class ImageSizeTests
    {
        [Test]
        public void Constructor_InitializesPropertiesCorrectly()
        {
            ImageSize imageSize = new ImageSize("Medium", 1024, 768);
            Assert.AreEqual(1024, imageSize.Width);
            Assert.AreEqual(768, imageSize.Height);
            Assert.IsTrue(imageSize.IsValid);
        }

        [Test]
        public void Constructor_WithZeroSize_InitializesPropertiesCorrectly()
        {
            ImageSize imageSize = new ImageSize("Custom", 0, 0);
            Assert.AreEqual("Custom", imageSize.Description);
            Assert.AreEqual(0, imageSize.Width);
            Assert.AreEqual(0, imageSize.Height);
            Assert.IsFalse(imageSize.IsValid);
        }

        [Test]
        public void ReferenceEquality()
        {
            ImageSize x = new ImageSize("Medium", 1024, 768);

            Assert.IsFalse(x.Equals(null));
            Assert.IsTrue(x.Equals(x));
        }

        [Test]
        public void ImageSizesAreEqual_IfWidthAndHeightAreEqual_IgnoringDescription()
        {
            ImageSize x = new ImageSize("Medium", 1024, 768);
            ImageSize y = new ImageSize("Biggish", 1024, 768);

            Assert.AreEqual(x, y);
            Assert.That(x == y);
            Assert.That(x.GetHashCode() == y.GetHashCode());
        }

        [Test]
        public void ImageSizesAreNotEqual_IfWidthsAreNotEqual_WithSameDescription()
        {
            ImageSize x = new ImageSize("Something", 1024, 768);
            ImageSize y = new ImageSize("Something", 1024, 600);

            Assert.AreNotEqual(x, y);
            Assert.That(x != y);
        }

        [Test]
        public void ImageSizesAreNotEqual_IfHeightsAreNotEqual_WithSameDescription()
        {
            ImageSize x = new ImageSize("Something", 1280, 768);
            ImageSize y = new ImageSize("Something", 1024, 768);

            Assert.AreNotEqual(x, y);
            Assert.That(x != y);
        }
    }
}